package com.android.monee.view.binding.widget;

import com.android.monee.binding.Field;

import android.text.TextWatcher;
import android.widget.TextView;

public class BindableTextViewDecorator {

	private TextView tv;
	
	public BindableTextViewDecorator(TextView tv){
		this.tv = tv;
	}

	public void addTextChangedListener(TextWatcher watcher) {
		tv.addTextChangedListener(watcher);
	}
	
	public CharSequence getText() {
		return tv.getText();
	}

	public final void setText(CharSequence text) {
		tv.setText(text);
	}

	public class Text implements Field<BindableTextViewDecorator, String>{

		@Override
		public String get(BindableTextViewDecorator obj) {
			return obj.getText().toString();
		}

		@Override
		public void set(BindableTextViewDecorator obj, String val) {
			obj.setText(val);			
		}
		
	}
}
